package com.itheima.reggie.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Slf4j
public class RedisTestController {

    @Autowired
    private RedisTemplate redisTemplate;
    @GetMapping
    public String testRedis() {
        //设置值到
        redisTemplate.opsForValue().set("name","lucy");

         //从 redis 获取值
         String name = (String)redisTemplate.opsForValue().get("name");
         return name;
    }
}
